package common.data.admin
{
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;

	/**
	 * 命令服务类
	 */
	public class LoginService extends RemoteObject
	{
		public var checkSessionCallBack:Function;
		public var checkSessionFailCallBack:Function;
		
		public var getLoginInfoCallBack:Function;
		public var debugLoginCallBack:Function;
		public var locateLoginCallBack:Function;
		
		public var getChinaAreaListCallBack:Function;
		public var getTradeListCallBack:Function;
		public var refreshDepsCallBack:Function;
		public var refreshDepsStaffsCallBack:Function;
//		public var refreshClientInfoCallBack:Function;
		
		
		public function LoginService() {
			super("loginService");
			this.showBusyCursor = false;
			this.getOperation("checkSession").addEventListener(ResultEvent.RESULT,checkSessionResult,false,0,true);
			this.getOperation("checkSession").addEventListener(FaultEvent.FAULT,failCallBack,false,0,true);
		
			this.getOperation("getLoginInfo").addEventListener(ResultEvent.RESULT,getLoginInfoResult,false,0,true);
			this.getOperation("debugLogin").addEventListener(ResultEvent.RESULT,debugLoginResult,false,0,true);
			this.getOperation("locateLogin").addEventListener(ResultEvent.RESULT,locateLoginResult,false,0,true);
			
			this.getOperation("getChinaAreaList").addEventListener(ResultEvent.RESULT,getChinaAreaListResult,false,0,true);
			this.getOperation("getTradeList").addEventListener(ResultEvent.RESULT,getTradeListResult,false,0,true);
			this.getOperation("refreshDeps").addEventListener(ResultEvent.RESULT,refreshDepsResult,false,0,true);
			this.getOperation("refreshDepsStaffs").addEventListener(ResultEvent.RESULT,refreshDepsStaffsResult,false,0,true);
//			this.getOperation("refreshClientInfo").addEventListener(ResultEvent.RESULT,refreshClientInfoResult,false,0,true);
			
		}
		
		public function checkSession(userName:String,password:String,companyId:String,clickMenuIds:Array=null):void{
			this.getOperation("checkSession").send(userName,password,companyId,clickMenuIds);
		}
		public function getLoginInfo():void{
			this.getOperation("getLoginInfo").send();
		}
		public function locateLogin(userName:String,password:String):void{
			this.getOperation("locateLogin").send(userName,password);
		}
		public function debugLogin(userName:String):void{
			this.getOperation("debugLogin").send(userName);
		}
		public function getChinaAreaList():void{
			this.getOperation("getChinaAreaList").send();
		}
		public function getTradeList():void{
			this.getOperation("getTradeList").send();
		}
		public function refreshDeps():void{
			this.getOperation("refreshDeps").send();
		}
		public function refreshDepsStaffs():void{
			this.getOperation("refreshDepsStaffs").send();
		}
//		public function refreshClientInfo():void{
//			this.getOperation("refreshClientInfo").send();
//		}
		
		
		private function checkSessionResult(e:ResultEvent):void{
			try{
				checkSessionCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function failCallBack(e:FaultEvent):void{
			try{
				checkSessionFailCallBack.apply(this,[e]);
			}catch(error:Error){
				trace(error.getStackTrace());
			}
		}
		private function getLoginInfoResult(e:ResultEvent):void{
			getLoginInfoCallBack.apply(this,[e]);
		}
		private function debugLoginResult(e:ResultEvent):void{
			debugLoginCallBack.apply(this,[e]);
		}
		private function locateLoginResult(e:ResultEvent):void{
			locateLoginCallBack.apply(this,[e]);
		}
		private function getChinaAreaListResult(e:ResultEvent):void{
			getChinaAreaListCallBack.apply(this,[e]);
		}
		private function getTradeListResult(e:ResultEvent):void{
			getTradeListCallBack.apply(this,[e]);
		}
		private function refreshDepsResult(e:ResultEvent):void{
			refreshDepsCallBack.apply(this,[e]);
		}
		private function refreshDepsStaffsResult(e:ResultEvent):void{
			refreshDepsStaffsCallBack.apply(this,[e]);
		}
//		private function refreshClientInfoResult(e:ResultEvent):void{
//			refreshClientInfoCallBack.apply(this,[e]);
//		}
		
	}
}	